﻿namespace KTWpm.Management.Domain.ValueObjects;

public record BreedId
{
    private readonly IBreadService _breadService;
    public Guid Value { get; set; }

    private BreedId(Guid value)
    {
        Value = value;
    }

    public static BreedId Create(Guid value)
    {
        return new BreedId(value);
    }

    public BreedId(Guid value, IBreadService breadService)
    {
        this._breadService = breadService;
        ValidateBread(value);
        Value = value;
    }

    private void ValidateBread(Guid value)
    {
        if (_breadService.GetBreed(value) == null)
        {
            throw new ArgumentException($"Breed with id {value} does not exist.");
        }
    }
}
